<template>
    <div class="">
  
      <ELTable v-bind="configTable" ref="searchsubmit">
  
          <template #search="{ searchSubmit, params }">
          <div>
            <el-form :inline="true" class="demo-form-inline">
              <el-form-item label="关键字">
                <el-input v-model="params.key" placeholder="请输入关键字" />
              </el-form-item>
              <el-form-item label="">
                <el-button type="primary" @click="searchSubmit">查询</el-button>
              </el-form-item>
            </el-form>
          </div>
        </template>
  
  
          <template #buttons="{ deleteAllHandle }">
          <div>
            <el-button type="primary" @click="add">添加</el-button>
            <el-button type="danger" @click="deleteAllHandle">删除</el-button>
          </div>
        </template>
          <template #operate="{ scope, delrow }">
          <div>
            <el-button type="primary" @click="change(scope.row.id)">修改</el-button>
            <el-button type="danger" @click="delrow(scope.row.id)">删除</el-button>
          </div>
        </template>
      </ELTable>
      <advertisementAdd v-if="showadd" @close="close" :id="id" @update="update"></advertisementAdd>
    </div>
  </template>
  
  <script lang='ts' setup>
  import { ref,watch,reactive } from "vue"
  import ELTable,{TableType} from "../../components/ELTable.vue";
  import { advertisementlist,adtypelist } from "../../service/advertisement/advertisement"
  import { column } from './advertisement'
  import advertisementAdd from "../../components/advertisementAdd.vue";
  
  const configTable: TableType = reactive({
      column: column,
      isSelection: true,
      loadData: advertisementlist,
      searchParams:{
        state:0
      }
  })

  const id = ref(0)
  const searchsubmit = ref()
  const showadd = ref<boolean>(false)

const close = ()=>{
  showadd.value = false
}

const update = ()=>{
  searchsubmit.value.searchSubmit()
}
const add = ()=>{
  showadd.value = true
}

const change = (ids:number)=>{
  showadd.value = true
  id.value=ids
}
  </script>
  
  <style  scoped>
  </style>
  